package main;

import java.util.HashMap;
import java.util.Vector;

public class Expirement {

private int reward;
private Vector<Integer> preReq;
private HashMap<String,Integer> reqEquipment;
private int Runtime;
private double realtimeRunning;
private String Spec;
private int Status;
private int ID;

	public Expirement(int reward, Vector<Integer> preReq, HashMap<String,Integer> reqEquipment, int runtime, String spec, int iD) {
		this.preReq=new Vector<Integer>();
		if(preReq!=null)
		{
			for(int i=0;i<preReq.size();i++)
			this.preReq.add(new Integer(preReq.elementAt(i)));
		}
		Status=0;
		this.reward = reward;
		this.reqEquipment = reqEquipment;
		this.Runtime = runtime;
		Spec = new String(spec);
		this.ID = iD;
		this.realtimeRunning=0;
	}

	public HashMap<String, Integer> getReqEquipment() {
		return reqEquipment;
	}

	public Vector<Integer> getReqExperiments() {
		return preReq;
	}

	public int getRuntime()
	{
		return Runtime;
	}
	public void addReqEquipment(String name,Integer amount)
	{
		reqEquipment.put(name, new Integer(amount));
	}

	public int getID() {
		return ID;
	}
	
	public void removePrerequiredExperiment(int experimentID) {
		for(int i=0;i<preReq.size();i++)
		{
			if(experimentID==preReq.elementAt(i).intValue())
				preReq.remove(i);
		}
	}

	public boolean hasPrerequirementsMet()
	{
		return preReq.isEmpty();
	}

	public int getStatus(){
		return Status;
	}

	public String getSpec()
	{
		return Spec;
	}

	public void setStatus(int i) {
		Status=i;	
	}

	public int getReward()
	{
		return reward;
	}
	
	public double getRealtimeRunning()
	{
		return realtimeRunning;
	}
	
	public String toString() {
		StringBuilder ans = new StringBuilder("Experiment "+ID);
		ans.append(" with specialization at ");
		ans.append(Spec);
		ans.append(" and runtime ");
		ans.append(Runtime);
		ans.append(", finished after ");
		ans.append(realtimeRunning);
		ans.append(" hours, and won reward of:");
		if(Runtime*1.15>=realtimeRunning)
			ans.append(reward);
		else
			ans.append(reward*0.10);
		ans.append(" zuzim.");
		return ans.toString();
	}

	
	public void updateRealtimeRunning(long realtimerun) {
		realtimeRunning=realtimerun;
	}
}
